package com.keba.lamp.ai.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.keba.basic.interfaces.echo.EchoService;
import com.keba.lamp.ai.entity.AiCustomer;
import com.keba.lamp.ai.service.AiCustomerService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import com.keba.basic.base.controller.SuperController;
import com.keba.lamp.ai.service.AiApplicationService;
import com.keba.lamp.ai.entity.AiApplication;
import com.keba.lamp.ai.vo.save.AiApplicationSaveVO;
import com.keba.lamp.ai.vo.update.AiApplicationUpdateVO;
import com.keba.lamp.ai.vo.result.AiApplicationResultVO;
import com.keba.lamp.ai.vo.query.AiApplicationPageQuery;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * 应用表
 * </p>
 *
 * @author twg
 * @date 2025-03-02 19:36:35
 * @create [2025-03-02 19:36:35] [twg] [代码生成器生成]
 */
@Slf4j
@RequiredArgsConstructor
@Validated
@RestController
@RequestMapping("/aiApplication")
@Tag(name = "应用表")
public class AiApplicationController extends SuperController<AiApplicationService, Long, AiApplication
        , AiApplicationSaveVO, AiApplicationUpdateVO, AiApplicationPageQuery, AiApplicationResultVO> {
    private final EchoService echoService;

    private final AiCustomerService aiCustomerService;

    @Override
    public EchoService getEchoService() {
        return echoService;
    }


    @Override
    public void handlerResult(IPage<AiApplicationResultVO> page) {
        page.getRecords().forEach(item -> {
            AiCustomer customer = aiCustomerService.getById(item.getCustomerId());
            item.getEchoMap().putIfAbsent("customerId", null != customer ? customer.getName() : "");
        });
    }
}


